Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 | import { useQuery } from '@tanstack/react-query';
import { useTranslation } from 'react-i18next';
import { resellerService } from '@/services/reseller';
export function useResellerCredits() {
const { t } = useTranslation();
return useQuery({
queryKey: ['reseller-credits'],
queryFn: async () => {
const result = await resellerService.getCreditBalance();
if (result.success) {
return result.data;
}
throw new Error(result.error?.error || t('common.serverError'));
},
refetchInterval: 30000, // Refetch every 30 seconds
staleTime: 10000, // Consider data stale after 10 seconds
});
}
|